<?php //$this->beginContent('application.views.layouts.main'); 
$this->beginContent('/layouts/main');?>

<?php
$model = UserProfiles::model()->findbyPk(Yii::app()->user->id);
?>
<div id="main-content">
    <?php echo $content; ?>
</div>
<div id="sidebar">
    <div class="sidebar-box border-line">
        <div class="sidebar-title">Search Events</div>
        <div class="sidebar-content">
            <?php $this->widget("application.components.Search");?>
        </div>
    </div>
<?php
if(Yii::app()->user->name=='admin')
{ ?>
    <div class="sidebar-box border-line">
        <div class="sidebar-title">Administrator</div>
        <div class="sidebar-content">
            <?php $this->widget('zii.widgets.CMenu',array(
			'items'=>$this->menu,
		)); ?>
        <div class="clear"></div>
        </div>
    </div>
<?php } ?>
<?php
if(!Yii::app()->user->isGuest)
{ ?>
    <div class="sidebar-box border-line">
        <div class="sidebar-title">User Control Panel</div>
        <div class="sidebar-content">
			<div class="comment-avatar border-shadow"><img src="<?php if($model!=null AND $model->avatar!=null){?><?php echo Yii::app()->request->baseUrl;?>/data/<?php echo $model->avatar;} else echo Yii::app()->request->baseUrl."/images/noavatar.gif";?>" height="80px" width="80px" /></div>
            <div class="comment-owner"><font color="black" style="font-weight: normal;">Hello </font>
            <?php 
				if($model != null)
					echo CHtml::link(CHtml::encode($model->display_name), array('viewprofiles', 'id'=>Yii::app()->user->id));
				else
					echo CHtml::link(CHtml::encode(Yii::app()->user->name), array('viewprofiles', 'id'=>Yii::app()->user->id));
			?>
            </div>
            <div class="comment-time">
            <?php $this->widget('zii.widgets.CMenu',array(
    			'items'=>array(
                    array('label'=>'ControlPanel', 'url'=>array('users/viewprofiles', 'id'=>Yii::app()->user->id), 'visible'=>!Yii::app()->user->isGuest),
    				array('label'=>'(Logout)', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
    			),
    		)); ?>
            </div>
            <div class="clear"></div>
        </div>
    </div>
<?php } ?>
    <div class="sidebar-box border-line">
        <div class="sidebar-title">Categories</div>
        <div class="sidebar-content">
        <span><?php echo CHtml::link('Events by Type', array('event/type')); ?></span>
        <ul>
    <?php 
    $model = Typeevent::model()->findAll(array('order'=>'name')); 
    foreach ($model as $type): ?>
            <li><?php echo CHtml::link(CHtml::encode($type['name']), array('category', 'type'=>$type['name'])); ?></li>
    <?php endforeach; ?>
        </ul>
        <div class="clear"></div>
        <span><?php echo CHtml::encode('Events by Times'); ?></span>
    
    <?php $menu_by_time=array(
        array('label'=>'Today', 'url'=>array('event/time','time'=>'today')),
    	array('label'=>'Tomorrow', 'url'=>array('event/time','time'=>'tomorrow')),
    	array('label'=>'This Week', 'url'=>array('event/time','time'=>'thisweek')),
        array('label'=>'This Month', 'url'=>array('event/time','time'=>'thismonth')),
        array('label'=>'All Events', 'url'=>array('event')),
    ); ?>
    <?php $this->widget('zii.widgets.CMenu', array('items'=>$menu_by_time));?>
        <div class="clear"></div>
        <span>BirthDay in Today</span>
			<ul>
			<?php 
				$model_birth = new UserProfiles;
				$result = $model_birth->getBirthDay(); ?>
			<?php $this->widget('zii.widgets.CListView', array(
					'dataProvider'=>$result,
					'itemView'=>'_viewpro',
					'summaryText'=>Yii::t('zii',""),
			));?>
			</ul>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div class="clear"></div>
<?php $this->endContent(); ?>